import java.security.*;
public class DigestPass{
    public String MD5(String cipher) throws Exception{
        MessageDigest m=MessageDigest.getInstance("MD5");
        m.update(cipher.getBytes("UTF8"));
        byte s[ ]=m.digest( );
        String result="";
        for (int i=0; i<s.length; i++){
            result+=Integer.toHexString((0x000000ff & s[i]) |
                    0xffffff00).substring(6);
        }
        System.out.println("MD5加密后的结果："+result);
        return  result;
    }
}